#include <stdio.h>
#include <unistd.h>
#include <sys/epoll.h>

int main()
{
	struct epoll_event ev, *event;

	int epfd = epoll_create(2);
	if (epfd < 0)
		perror("epoll_create()");

	ev.events = EPOLLIN | EPOLLET;
	ev.data.fd = 0;

	if (epoll_ctl(epfd, EPOLL_CTL_ADD, 0, &ev) != 0)
	{
		perror("epoll_ctl()");
		exit(1);
	}

	int nfds = epoll_wait(epfd, event, 2, 3000);

	if (nfds < 0)
		perror("epoll_wait()");
	else if(nfds)
		printf("Data is available now.\n");
	else
		printf("No data within five second.\n");

	return 0;
}

